knitr::opts_chunk$set(echo = TRUE)

The basic example vignette took you through, well, the basics. But it wasn't particularly realistic, because if you already had all your data in R, you probably wouldn't need to be learning basic R. Most likely the data you need to work with right now is somewhere else.

This vignette will walk you through laoding an excel file and using some of the more advanced options in excelTransition to make the workflow easier to use.

Let's start from the beginning again and load the required packages. As we've already installed them, we can skip the install.packages() step. (And we don't need the devtools package this time as we're not installing a package from github.)

library(readxl) # readxl is the package which allows you to load Excel files in R
library(ggplot2) # everybody likes charts, this is a great package to work with
library(openxlsx) # a package for writing excel files

library(excelTransition) # this is the package where the excelTransition functions live

So far so good, let's load our dataset. Let's try something a little more relevant to modern business than 14th century crop yields this time. To that end, we'll be using the loanbook from the Australian arm of Ratesetter, which is a fintech company. Ratesetter specialises in marketplace lending: people can apply for a loan and other people can fund it. They publish their loanbook every quarter and the loanbook we'll be using is from 30th September, 2017.

The spreadsheet is located in the data folder of the excelTransition package. You may need to change the path name to the data. The sheet argument tells R which sheet in the workbook it should read, while col_names tells R whether to look for column names to keep for each variable. The data doesn't start until row 9, so skip = 8 tells R to skip all the irrelevant bits at the top.

loanBook <- read_xlsx("../data/20170930loanbook.xlsx", sheet = "RSLoanBook",
                      col_names = TRUE, skip = 8)
            # Here, I'm loading the spreadsheet

In the basic example, the output from makeDescriptives() was just put in the current working directory. You generally want to choose where your output goes. I suggest making an output folder in your current directory. After that you can direct output - that's what the outputName argument is doing here. You may also want to choose the number of decimal places your descriptive statistics are rounded to. The default is 2 if you don't specify. Here roundDP specifies how much rounding.

outputName <- "output/descriptives.xlsx"
roundDP <- 3

myResults <- makeDescriptives(loanBook, roundDP, outputName) 
                # get the basic descriptives similar to Excel.

Likewise, you want to be able to put the charts somewhere you choose. There's an optional argument in makeCharts() to manage this too.

pathName <- "output/"
makeCharts(loanBook, pathName)


stephdesilva/excelTransition documentation built on May 19, 2019, 3:05 a.m.